/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Service.Balance2TransferService;
import Util.ServiceResponseObject;
import Util.TranslatorUtils;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import th.co.tac.esv.pre.ejb.dat.balance.transfer.BalanceTransferResponse;
import th.co.tac.esv.pre.web.util.conf.LogUtil;

/**
 *
 * @author Gr-Developer
 */
public class Balance2TransferController extends BaseController {

    public Balance2TransferController() {
        super("Balance2TransferController.properties",
                LogUtil.BalanceTransferWebLogger,
                LogUtil.BalanceTransferWebTrnsLogger);
    }

    @Override
    protected String verifyPageView(String pageName, HttpServletRequest request)
            throws Exception {
        Balance2TransferService service = new Balance2TransferService();

        BalanceTransferResponse resp = service.balance2transfer(request);
        ServiceResponseObject sro = new ServiceResponseObject(
                resp.getErrorStatus(),resp.getErrorCode(),
                resp.getErrorMessage(), resp.getErrorTuxMsgSqlCode(),
                resp.getErrorTuxMsgTextEng(), resp.getErrorTuxMsgTextThai(),
                resp);

        if (sro.getResult()) {
            return super.verifyPageView(pageName, request);
        } else {
            mv.addObject("ERROR_MESSAGE", TranslatorUtils.oneEscape(sro.getErrorMsg()));
            return "Template/Error";
        }
    }
}
